/**
 * 
 */
package com.gko100.action;

import java.util.List;

import com.gko100.action.base.AdminBaseAction;
import com.gko100.model.AdminPerm;
import com.gko100.model.Administrator;
import com.gko100.model.Permission;

/**
 * @author Administrator
 *
 */
public class AdminPermAction extends AdminBaseAction {
	
	private AdminPerm adminPerm;
	private Permission perm;
	private Administrator admin;
	private List<Permission> permList;
	private Integer[] permIdList;
	private List<AdminPerm> adminPermList;
	
	public AdminPerm getAdminPerm() {
		return adminPerm;
	}
	public void setAdminPerm(AdminPerm adminPerm) {
		this.adminPerm = adminPerm;
	}
	
	public Permission getPerm() {
		return perm;
	}
	public Administrator getAdmin() {
		return admin;
	}
	
	public void setAdmin(Administrator admin) {
		this.admin = admin;
	}
	public void setPerm(Permission perm) {
		this.perm = perm;
	}
	
	public List<Permission> getPermList() {
		return permList;
	}
	public void setPermList(List<Permission> permList) {
		this.permList = permList;
	}
	public List<AdminPerm> getAdminPermList() {
		return adminPermList;
	}
	public void setAdminPermList(List<AdminPerm> adminPermList) {
		this.adminPermList = adminPermList;
	}
	
	public Integer[] getPermIdList() {
		return permIdList;
	}
	public void setPermIdList(Integer[] permIdList) {
		this.permIdList = permIdList;
	}

	
	//---------------------action方法---------------------
	
	
	
	
	
	
	public String upload_adminPerm(){
		
		List<AdminPerm> adminPermList = adminManager.findAdminPermListByAdminId(this.getAdmin().getAdminId());
		Integer[] permIdList = new Integer[20];
		for(int i=0; i<adminPermList.size();i++){
			if(adminPermList.get(i).getPermValue()){
				permIdList[i]=adminPermList.get(i).getPerm().getPermId();
				System.out.println("permIdList======"+permIdList[i]);
			}
		}
		this.setPermIdList(permIdList);
		
		List<Permission> permList = adminManager.findPermList();
		this.setPermList(permList);

		return "adminPerm_upload_success";
	}
	
	public String modify_adminPerm() throws Exception {
		
		adminManager.modify_adminPermByAdminPermId(this.getAdmin().getAdminId(),this.getPermIdList());
		return "adminPerm_modify_success";
	}
	
	
}
